<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class MyCar extends Model
{
    protected $table='park_mycar';
    protected $guarded=[];
    protected $primaryKey='ID';
    public $timestamps=false;
    
    protected static function boot()
    {
        parent::boot();
        
        static::addGlobalScope('notSell', function(Builder $builder) {
            $builder->where('isSale', 0);
        });
    }
    
    public function car()
    {
        return $this->hasOne(Car::class,'CarID','CarID');
    }
    
    public function user()
    {
        return $this->hasOne(Member::class,'uid','uid');
    }
    
}
